package
{
	import com.NHL.modules.map.vo.MapVo;
	import com.NHL.single.ESource;
	import com.NHL.single.MapLoader;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	
	public class Test extends Sprite
	{
		private var vo:MapVo
		private var container:Sprite
		public function Test()
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			super();
			container = new Sprite();
			addChild(container);
			vo = new MapVo();
			vo.PERHEIGHT = 200;
			vo.PERWIDTH = 200;
			vo.width = 2714;
			vo.height = 1256;
			vo.id = "世界文字地图"
			MapLoader.getInstance().add(vo,result);
			container.addEventListener(MouseEvent.MOUSE_DOWN,onDown,false,0,true);
		}
		
		private function onDown():void
		{
			container.startDrag();
			//stage.addEventListener(MouseEvent.MOUSE_MOVE,onMove,false,0,true),
			stage.addEventListener(MouseEvent.MOUSE_UP,onUp,false,0,true);	
		}
		
		private function onUp():void
		{
			container.stopDrag();
		}
		
		private function result():void
		{
			var bmdArr:Vector.<BitmapData> = ESource.getInstance().getMap(vo.id);
			var _bmd:BitmapData = new BitmapData(vo.width,vo.height);
			var mtx:Matrix = new Matrix();
			var w:int = Math.ceil(vo.width/vo.PERWIDTH);
			var h:int = Math.ceil(vo.height/vo.PERHEIGHT);
			//for(var k:int = 0;k< 2;k++)
				for(var i:int = 0;i < w;i++)
					for(var j:int = 0;j < h;j++)
					{
						mtx.identity();
						mtx.tx = i*vo.PERWIDTH;
						mtx.ty  = j*vo.PERHEIGHT;
						_bmd.draw(bmdArr[i*h+j],mtx);
					}
			var bmp:Bitmap = new Bitmap();
			bmp.bitmapData = _bmd;
			container.addChild(bmp);
		}
		
	}
}